<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .el-tabs__item.is-active{
      color: #058142;
    }.el-tabs__active-bar{
      background-color: #058142;
    }.el-tabs{
      background-color: #fff;
    }.el-input__inner{
      border: 0;
      font-size: 1rem;
      text-align: center;
    }.el-input__prefix{
      display: none;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">团队执行力-门店个人排名</div>
      </div>
      <!--  -->
      <div class="x-ico-month">
        <el-date-picker v-model="cardsmonth" type="month" placeholder="选择月" @change="getmonth" format="yyyy 年 MM 月" value-format="yyyyMM" :editable="notkey"></el-date-picker>
      </div>
      <!--  -->
      <div class="swiper-container" style="border-top-left-radius:.6rem;border-top-right-radius:.4rem;background-color:#fff;">
        <div class="swiper-wrapper">
          <div class="swiper-slide x-train-items" v-for="(item,index) in namelist" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
        </div>
      </div>
      <!--  -->
      <!-- <div class="x-target-num">
        <div class="x-target-t">系统参与店面:</div>
        <div class="x-mytop-r">{{monthnum}}</div>
      </div>
      <div class="x-target-num">
        <div class="x-target-t">本组参与店面:</div>
        <div class="x-mytop-r">{{monthnum}}</div>
      </div> -->
      <template>
        <el-table :data="tableData">
          <el-table-column label="姓名" width="" fixed>
            <template slot-scope="scope">
              {{scope.row.username}}
            </template>
          </el-table-column>
          <el-table-column :label="'本人执行力指数 \n 当月累计/当年累计 /累计点赞'" width="130" prop="plan_income">
            <template slot-scope="scope">
              {{scope.row.month_num}}/{{scope.row.year_num}}/{{scope.row.zan_num}}
            </template>
          </el-table-column>
          <el-table-column :label="'本组排名 \n 月排名/年排名 /热度排行'" width="" prop="actual_income">
            <template slot-scope="scope">
              {{scope.row.group_month_rank}}/{{scope.row.group_year_rank}}/{{scope.row.group_zan_rank}}
            </template>
          </el-table-column>
          <el-table-column :label="'系统排名 \n 月排名/年排名 /热度排行'" width="" prop="plan_rate">
            <template slot-scope="scope">
              {{scope.row.sys_month_rank}}/{{scope.row.sys_year_rank}}/{{scope.row.sys_zan_rank}}
            </template>
          </el-table-column>
        </el-table>
      </template>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          cardsmonth:'',
          notkey:false,
          tableData:[],
          monthnum:'',
          namelist:[],
          curId:0,
          cateid:'',
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        if(month<10){
          month = '' + 0 + month;
        }
        var toMonth = '' + year + month ;
        that.cardsmonth = toMonth;
        that.getcate()

      },
      methods: {
        //获取分类
        getcate:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/company/jobList',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                for(var i=0;i<ret.data.length;i++){
                  that.namelist.push({
                    title:ret.data[i].title,
                    id:ret.data[i].id
                  })
                }
                that.cateid = ret.data[0].id;
                that.$nextTick(function(){
                  var mySwiper = new Swiper('.swiper-container',{
                    freeMode: true,
                    loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                    slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                    slidesPerView: 2.5,
                    centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                    spaceBetween: 10,//slide之间设置距离
                    slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                    slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量
                  });
                });
                that.getdatafirst()
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //
        changetab:function(index,id){
          var that = this;
          console.log(id);
          that.cateid = id;
          that.curId = index;
          that.getdatafirst()
        },
        //
        getmonth:function(val){
          var that = this;
          that.cardsmonth = val;
          that.getdatafirst()
        },
        //
        getdatafirst:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/task/memberRank',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.cardsmonth,
                deptid:that.cateid,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.tableData = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
